<?php
namespace AuctionCore\Account;


/**
* 唯一登录 单元测试
* @author       爱民
*/
class UniqLoginTest extends \PHPUnit_Framework_TestCase
{

	public function test(){
		 $ul = new \AuctionCore\Account\UniqLogin();
		 $uid = '123';

		 $token = $ul->update($uid);					//更新唯一登录（此放在登录成功的地方调用）
		 $this->assertTrue($ul->check($uid,$token));	 //检查唯一登录token	（每个功能的basecontroll设置唯一登录检查） 		 

		 $token2 = $ul->update($uid);					//模拟再次更新唯一登录

		 $this->assertTrue(!$ul->check($uid,$token));   //再次检查第一次唯一登录token
		 $this->assertTrue($ul->check($uid,$token2));   //检查第二次唯一登录token

	}


	public function testDes(){
		$crypt = new \AuctionCore\Common\Des($key);

		$key = '20120401';
		$plain = 'abcd';
		$encrypt = $crypt->encrypt($key, $plain);
		$decrypt = $crypt->decrypt($key, $encrypt);

		/*echo 'plain = '.$plain."\r\n";
		echo 'encrypt = '.$encrypt."\r\n";
		echo 'decrypt = '.$decrypt."\r\n";*/

		$this->assertTrue($decrypt==$plain);
	}

}

?>